import Conditions from '../../../../../resources/conditions';
import { Responses } from '../../../../../resources/responses';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';

export interface Data extends RaidbossData {
  calledWildSpeed?: boolean;
  calledUseCannon?: boolean;
}
const triggerSet: TriggerSet<Data> = {
  id: 'CastrumAbania',
  zoneId: ZoneId.CastrumAbania,
  timelineFile: 'castrum_abania.txt',
  timelineTriggers: [
    {
      id: 'CastrumAbania Magna Roader Wheel',
      // no cast, untelegraphed tankbuster
      regex: /Wheel/,
      beforeSeconds: 4,
      response: Responses.tankBuster(),
    },
    {
      id: 'CastrumAbania Subject Number XXIV Sparking Current',
      // no cast, line AoEs on each player
      regex: /Sparking Current/,
      beforeSeconds: 4,
      response: Responses.spread(),
    },
  ],
  triggers: [
    {
      id: 'CastrumAbania Magna Roader Fire III',
      type: 'StartsUsing',
      netRegex: { source: 'Magna Roader', id: '1F16', capture: false },
      response: Responses.aoe(),
      run: (data) => data.calledWildSpeed = data.calledUseCannon = false,
    },
    {
      id: 'CastrumAbania Magna Roader Wild Speed',
      type: 'StartsUsing',
      netRegex: { source: 'Magna Roader', id: '207E', capture: false },
      // This repeats indefinitely, so only call the first one per Wild Speed phase.
      condition: (data) => !data.calledWildSpeed,
      delaySeconds: 6,
      response: Responses.killAdds(),
      run: (data) => data.calledWildSpeed = true,
    },
    {
      id: 'CastrumAbania Magna Roader Mark XLIII Mini Cannon',
      type: 'NameToggle',
      netRegex: { name: 'Mark XLIII Mini Cannon', toggle: '01', capture: false },
      // There's two cannons, so only say something when the first one is targetable.
      condition: (data) => !data.calledUseCannon,
      delaySeconds: 6,
      suppressSeconds: 1,
      infoText: (_data, _matches, output) => output.text!(),
      run: (data) => data.calledUseCannon = true,
      outputStrings: {
        text: {
          en: 'Fire cannon at boss',
          de: 'Feuere Kanonen auf den Boss',
          fr: 'Tirez le canon sur le boss',
          cn: '用炮射BOSS',
          ko: '보스 파동탄 맞추기',
        },
      },
    },
    {
      id: 'CastrumAbania Subject Number XXIV Elemental Overload',
      type: 'StartsUsing',
      netRegex: { source: 'Subject Number XXIV', id: '82A[89A-D]', capture: false },
      response: Responses.aoe(),
    },
    {
      id: 'CastrumAbania Subject Number XXIV Fire II',
      type: 'HeadMarker',
      netRegex: { id: '00A1' },
      response: Responses.stackMarkerOn(),
    },
    {
      id: 'CastrumAbania Subject Number XXIV Blizzard II',
      type: 'HeadMarker',
      netRegex: { id: '0178' },
      condition: Conditions.targetIsYou(),
      response: Responses.spread(),
    },
    {
      id: 'CastrumAbania Subject Number XXIV Thunder II',
      type: 'StartsUsing',
      netRegex: { source: 'Subject Number XXIV', id: '82B8', capture: false },
      suppressSeconds: 1,
      infoText: (_data, _matches, output) => output.getTowers!(),
      outputStrings: {
        getTowers: {
          en: 'Get Towers',
          de: 'Türme nehmen',
          fr: 'Prenez les tours',
          ja: '塔を踏む',
          cn: '踩塔',
          ko: '장판 하나씩 들어가기',
        },
      },
    },
    {
      id: 'CastrumAbania Inferno Ketu Slash',
      type: 'StartsUsing',
      netRegex: { source: 'Inferno', id: ['1F26', '208B', '208C'] },
      response: Responses.tankBuster(),
    },
    {
      id: 'CastrumAbania Inferno Adds',
      type: 'AddedCombatant',
      netRegex: { npcNameId: '6270', capture: false },
      response: Responses.killAdds(),
    },
    {
      id: 'CastrumAbania Inferno Rahu Ray',
      type: 'HeadMarker',
      netRegex: { id: '004A' },
      condition: Conditions.targetIsYou(),
      response: Responses.spread(),
    },
    {
      id: 'CastrumAbania Inferno Rahu Comet',
      type: 'StartsUsing',
      // Rahu Comet (1F2B) does not do knockback until it has been empowered at least once.
      netRegex: { source: 'Inferno', id: ['2088', '2089'], capture: false },
      infoText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          // Knockback comes from the proximity marker, not the boss.
          en: 'Small comet knockback',
          de: 'Kleiner Kometenrückstoß',
          fr: 'Poussée de la petite comète',
          cn: '小彗星击退',
          ko: '작은 혜성 넉백',
        },
      },
    },
  ],
  timelineReplace: [
    {
      'locale': 'de',
      'replaceSync': {
        'Inferno': 'Inferno',
        'Magna Roader': 'Magna Rotula',
        'Mark XLIII Mini Cannon': 'Kleingeschütz Xliii',
        'Project Aegis': 'Projekt Aegis',
        'Subject Number XXIV': 'Experiment Nummer XXIV',
        'Terrestrial Weaponry': 'Bodenwaffenentwicklung',
        'The Assessment Grounds': 'Evaluationsgelände',
      },
      'replaceText': {
        '--adds--': '--Adds--',
        'Barrier Shift': 'Barrierewechsel',
        'Blizzard II': 'Eisra',
        'Elemental Overload': 'Elementarschub',
        '(?<!Magitek )Fire II(?!I)': 'Feura',
        'Gale Cut': 'Sturmschnitt',
        'Ice Grid': 'Eisgitter',
        'Ketu & Rahu': 'Ketoh & Rahu',
        'Ketu Cut': 'Ketoh-Schnitt',
        'Ketu Slash': 'Ketoh-Hieb',
        'Magitek Fire II(?!I)': 'Magitek-Feura',
        'Magitek Fire III': 'Magitek-Feuga',
        'Rahu Blaster': 'Rahu-Blaster',
        'Rahu Cut': 'Rahu-Schnitt',
        'Sparking Current': 'Elektrofunke',
        'Stab': 'Durchstoß',
        'System Error': 'Systemfehler',
        'Thunder II': 'Blitzra',
        'Towers': 'Türme',
        'Triflame': 'Dreifachflamme',
        'Wheel': 'Rad',
        'Wild Speed': 'Heißlaufen',
      },
    },
    {
      'locale': 'fr',
      'replaceSync': {
        'Inferno': 'Inferno',
        'Magna Roader': 'magna rouleur magitek',
        'Mark XLIII Mini Cannon': 'Mortier Type Xliii',
        'Project Aegis': 'Projet Aegis',
        'Subject Number XXIV': 'sujet expérimental Numéro XXIV',
        'Terrestrial Weaponry': 'Armement terrestre',
        'The Assessment Grounds': 'Terrain d\'évaluation',
      },
      'replaceText': {
        '--adds--': '--adds--',
        'Barrier Shift': 'Change-Barrière',
        'Blizzard II': 'Extra Glace',
        'Elemental Overload': 'Amplification élémentaire',
        '(?<!Magitek )Fire II(?!I)': 'Extra Feu',
        'Gale Cut': 'Chute de pointes',
        'Ice Grid': 'Lacis glacé',
        'Ketu & Rahu': 'Ketu et Rahu',
        'Ketu Cut': 'Dépassement Ketu',
        'Ketu Slash': 'Taillade Ketu',
        'Magitek Fire II(?!I)': 'Extra Feu magitek',
        'Magitek Fire III': 'Méga Feu magitek',
        'Rahu Blaster': 'Canon Rahu',
        'Rahu Cut': 'Dépassement Rahu',
        'Sparking Current': 'Courant étincelant',
        'Stab': 'Poignardage',
        'System Error': 'Erreur système',
        'Thunder II': 'Extra Foudre',
        'Towers': 'Tours',
        'Triflame': 'Triflamme',
        'Wheel': 'Roue',
        'Wild Speed': 'Course folle',
      },
    },
    {
      'locale': 'ja',
      'replaceSync': {
        'Inferno': 'インフェルノ',
        'Magna Roader': '魔導マグナローダー',
        'Mark XLIII Mini Cannon': 'Xliii式小臼砲',
        'Project Aegis': '強化実験房',
        'Subject Number XXIV': '実験体ナンバーXXIV',
        'Terrestrial Weaponry': '陸戦兵器開発房',
        'The Assessment Grounds': '性能試験場',
      },
      'replaceText': {
        '--adds--': '--雑魚--',
        'Barrier Shift': 'バリアチェンジ',
        'Blizzard II': 'ブリザラ',
        'Elemental Overload': 'エレメンタルブースト',
        '(?<!Magitek )Fire II(?!I)': 'ファイラ',
        'Gale Cut': '烈風殺',
        'Ice Grid': 'アイスグリッド',
        'Ketu & Rahu': 'ケトゥ＆ラフ',
        'Ketu Cut': 'ケトゥ・リミッターカット',
        'Ketu Slash': 'ケトゥ・スラッシュ',
        'Magitek Fire II(?!I)': '魔導ファイラ',
        'Magitek Fire III': '魔導ファイガ',
        'Rahu Blaster': 'ラフ・ブラスター',
        'Rahu Cut': 'ラフ・リミッターカット',
        'Sparking Current': 'カレントスパーク',
        'Stab': '刺突',
        'Towers': '塔',
        'System Error': 'システムエラー',
        'Thunder II': 'サンダラ',
        'Triflame': 'スリーフレイム',
        'Wheel': 'ホイール',
        'Wild Speed': '暴走',
      },
    },
    {
      'locale': 'cn',
      'replaceSync': {
        'Inferno': '炼狱炎魔',
        'Magna Roader': '魔导机车大魔',
        'Mark XLIII Mini Cannon': '43式小迫击炮',
        'Project Aegis': '强化实验室',
        'Subject Number XXIV': '024号',
        'Terrestrial Weaponry': '陆战兵器开发室',
        'The Assessment Grounds': '性能试验场',
      },
      'replaceText': {
        '--adds--': '--小怪--',
        'Barrier Shift': '护盾转换',
        'Blizzard II': '冰冻',
        'Elemental Overload': '元素过载',
        '(?<!Magitek )Fire II(?!I)': '烈炎',
        'Gale Cut': '烈风杀',
        'Ice Grid': '冰格',
        'Ketu & Rahu': '罗睺计都',
        'Ketu Cut': '计都限制器减档',
        'Ketu Slash': '计都挥',
        'Magitek Fire II(?!I)': '魔导烈炎',
        'Magitek Fire III': '魔导爆炎',
        'Rahu Blaster': '罗睺冲击波',
        'Rahu Cut': '罗睺限制器减档',
        'Sparking Current': '电流火花',
        'Stab': '突刺',
        'System Error': '系统错误',
        'Thunder II': '震雷',
        'Towers': '塔',
        'Triflame': '三炎',
        'Wheel': '车轮',
        'Wild Speed': '猛冲',
      },
    },
    {
      'locale': 'ko',
      'replaceSync': {
        'Inferno': '인페르노',
        'Magna Roader': '마도 마그나로더',
        'Mark XLIII Mini Cannon': 'XLIII식 소형 박격포',
        'Project Aegis': '강화실험실',
        'Subject Number XXIV': '실험체 XXIV호',
        'Terrestrial Weaponry': '지상 병기 개발실',
        'The Assessment Grounds': '성능 시험장',
      },
      'replaceText': {
        '--adds--': '--쫄--',
        'Barrier Shift': '보호막 변환',
        'Blizzard II': '블리자라',
        'Elemental Overload': '속성 충전',
        '(?<!Magitek )Fire II(?!I)': '파이라',
        'Gale Cut': '진공 칼날',
        'Ice Grid': '얼음 격자',
        'Ketu & Rahu': '케투와 라후',
        'Ketu Cut': '케투 리미터 해제',
        'Ketu Slash': '케투 난도질',
        'Magitek Fire II(?!I)': '마도 파이라',
        'Magitek Fire III': '마도 파이가',
        'Rahu Blaster': '라후 폭파',
        'Rahu Cut': '라후 리미터 해제',
        'Sparking Current': '전류 방사',
        'Stab': '찌르기',
        'System Error': '시스템 오류',
        'Thunder II': '선더라',
        'Towers': '기둥',
        'Triflame': '세 갈래 화염',
        'Wheel': '바퀴',
        'Wild Speed': '폭주',
      },
    },
  ],
};

export default triggerSet;
